package com.czmh.etc.onlinepubsys.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.czmh.etc.common.core.annotation.ApiVersion;
import com.czmh.etc.onlinepubsys.dto.EtcYueSaveApplyReqDTO;
import com.czmh.etc.onlinepubsys.feign.newrun.entity.yue.EtcYueBankCardInfo;
import com.czmh.etc.onlinepubsys.feign.newrun.entity.yue.EtcYueShippingInfo;
import com.czmh.etc.onlinepubsys.json.JsonResult;
import com.czmh.etc.onlinepubsys.services.YueService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @ClassName：YuePubController
 * @Description：粤通卡发行控制器
 * @Author： sevenchen.
 * @Date：2019/10/14 10:33.
 * @Version：1.0.0
 */
@RestController
@RequestMapping("/{version}/api/yue/")
@Api(tags = "ETC发行接口【新】-粤通卡")
public class YueController {
    @Autowired
    private YueService yueService;

    /**
     * 查询车辆是否已办理粤通卡
     * @param telePhoneNo 可为空! 手机号码
     * @param plateColor 不可为空! 车牌颜色: 0-蓝. 4-绿色.
     * @param plateNo 不可为空! 车牌号码
     * @return
     */
    @ApiVersion(1)
    @GetMapping(value = "queryIssue")
    @ApiOperation(value="查询车辆是否已办理粤通卡", notes = "查询车辆是否已办理粤通卡")
    public JsonResult queryIssue(@RequestParam(required = false) String mblNo,
                                 @RequestParam("plateColor") String plateColor,
                                 @RequestParam("plateNo") String plateNo){
        return yueService.queryIssue(mblNo, plateColor, plateNo);
    }

    @ApiVersion(1)
    @GetMapping(value = "querySignType")
    @ApiOperation(value = "根据证件号查询签约方式", notes = "根据证件号查询签约方式")
    public JsonResult querySignType(@RequestParam("certNo") String certNo){
        return yueService.querySignType(certNo);
    }

    @ApiVersion(1)
    @PostMapping(value = "saveApplyInfo")
    @ApiOperation(value = "保存申请信息", notes = "保存申请信息")
    public JsonResult saveApplyInfo(@RequestBody  EtcYueSaveApplyReqDTO saveApplyReqDTO, HttpServletRequest request) throws Exception{
        return yueService.saveApplyInfo(saveApplyReqDTO.getApplyInfo().getLoginUserId(), saveApplyReqDTO);
    }

    @ApiVersion(1)
    @PostMapping(value = "addShippingInfo")
    @ApiOperation(value = "添加收货信息", notes = "添加收货信息")
    public JsonResult addShippingInfo(@RequestBody EtcYueShippingInfo shippingInfo, HttpServletRequest request) throws Exception{
        return yueService.addShippingInfo(shippingInfo.getLoginUserId(), shippingInfo);
    }
    
    @ApiVersion(1)
    @PostMapping(value = "bindAccount")
    @ApiOperation(value = "银行卡绑定", notes = "银行卡绑定")
    public JsonResult bindAccount(@RequestBody EtcYueBankCardInfo bankCardInfo, HttpServletRequest request) throws Exception{
        return yueService.bindAccount(bankCardInfo.getLoginUserId(), bankCardInfo);
    }
    
    @ApiVersion(1)
    @GetMapping(value = "checkOrder")
    @ApiOperation(value = "单笔订单查询", notes = "单笔订单查询")
    public JsonResult checkOrder(String applyId) throws Exception{
        return yueService.checkOrder(applyId);
    }
}
